/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package unc.pds.facets;

import unc.pds.model.UserRemote;

/**
 *
 * @author Mikhail
 */
public class FriendsFacet implements Facet {
    public FriendsFacet(UserRemote user, boolean own) {
        this.user = user;
        this.own = own;
    }
    UserRemote user;
    boolean own;
    public String draw() throws Exception {
        String result = "";
        UserRemote[] friends = user.getFriends();
        result += "<h4>Друзья:</h4>";
        for (int i=0; i<friends.length; i++) {
            result += "<p><a href = \"index.jsp?id="+ friends[i].getKey() +"&view=posts\">"+ friends[i].getNickname() +"</a>";
            if (own) {
                result += " <a href = \"friend-processor.jsp?action=remove&id="+ friends[i].getKey() +"\"><img src=\"img/decline.png\" alt=\"Удалить\"/></a>";
            }
            result += "</p>\n";
        }
        return result;
    }
    public boolean isSide() {
        return false;
    }
}
